<%@page import="org.dom4j.Node"%><%@page import="java.util.List,java.util.Map"%><%@page import="org.dom4j.Element,org.dom4j.Attribute"%><%@page import="org.dom4j.Document"%><%@page import="com.ly.core.util.XmlUtil"%><%@page pageEncoding="UTF-8"%><%
	response.setContentType("text/xml");
	String filePath=pageContext.getServletContext().getRealPath("/js");
	filePath+="/menu.xml";
	Document doc=XmlUtil.load(filePath);
	String id=request.getParameter("id");
	Map rights=(Map)session.getAttribute("rights");
	if(doc!=null){
		StringBuffer sb=new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r");
		Element el=doc.getRootElement();
		List els = el.elements();
		for (int i = 0; i < els.size(); i++) {
			Element elv = (Element) els.get(i);
			if(!rights.containsKey(elv.attributeValue("id"))) el.remove(elv);
			else{
				//System.out.println(elv.attributeValue("id"));
				List elss=elv.getDocument().getRootElement().elements();
				for(int k=0;k<elss.size();k++){
					Element elvv = (Element) elss.get(k);
					//System.out.println(elvv.attributeValue("id"));
					if(!rights.containsKey(elvv.attributeValue("id"))) elss.remove(elvv);
					else{
						List elsss=elvv.elements();
						for(int j=0;j<elsss.size();j++){
							Element elvvv = (Element) elsss.get(j);
							//System.out.println(elvvv.attributeValue("id"));
							if(!rights.containsKey(elvvv.attributeValue("id"))) elsss.remove(elvvv);
							else{
								List elssss=elvvv.elements();
								for(int m=0;m<elssss.size();m++){
									Element elvvvv=(Element)elssss.get(m);
									if(!rights.containsKey(elvvvv.attributeValue("id"))) elssss.remove(elvvvv);
								}
							}
						}
					}
				}
			}
		}
		//System.out.println(el.asXML());
		List nodes=el.selectNodes("/Menus/Items[@id='"+id+"']/*");
		sb.append("<Menus>\r");
		for(int i=0;i<nodes.size();i++){
			Node node=(Node)nodes.get(i);
			sb.append(node.asXML());
		}
		sb.append("\r</Menus>\r");
		out.println(sb.toString());
	}
%>